<?php
// Author: dolphinigle
// 28 March 2012
include 'config/koneksi.php';

if ($_GET[type] == 'add') {
  $query = "SELECT COUNT(id_achievement) AS cnt FROM achievement " .
           "WHERE username='" . $_GET[username] . "' AND " .
           "isi='" . $_GET[id] . "'";
  $sql_answer = mysql_query($query);
  $ans = mysql_fetch_array($sql_answer);
  
  if ($ans[cnt] == 0) {
    // Add the achievement!
    $result = mysql_query("INSERT INTO achievement(username, isi) " .
                          "VALUES('" . $_GET[username] . "', '" .
                          $_GET[id] . "')");
    $i = $_GET[id];
    if ($i == 1) {
      echo "Cupu";
    } else if ($i == 2) {
      echo "Cupu-Cupu";
    } else if ($i == 3) {
      echo "Tidak Asertif";
    } else if ($i == 4) {
      echo "Menyebalkan";
    } else if ($i == 5) {
      echo "Sombong";
    } else if ($i == 6) {
      echo "Sampah Masyarakat";
    } else if ($i == 7) {
      echo "Gila";
    } else {
      echo "ERROR: UNKNOWN ACHIEVEMENT";
    }
  } else {
    echo "";
  }
} else {
  exit('UNRECOGNIZED TYPE PARAMETER');
}
?>
